package com.biu.billiards.controller;

import com.biu.billiards.model.vo.coupon.AddCouponVo;
import com.biu.billiards.model.vo.coupon.GetCouponVo;
import com.biu.billiards.model.vo.coupon.UpdateCouponVO;
import com.biu.billiards.response.BaseResponse;
import com.biu.billiards.response.RespGenerator;
import com.biu.billiards.service.ICouponService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xue
 * @since 2023-09-25
 */
@RestController
@RequestMapping()
public class CouponController {


    @Resource
    private ICouponService couponService;



    @ApiOperation(value = "获取优惠卷台球数据")
    @PostMapping("/getCouponPage")
    public BaseResponse<Map<String,Object>> getCouponPage(@RequestBody GetCouponVo getCouponVo) {

        return RespGenerator.returnOK(couponService.getCouponPage(getCouponVo));
    }


    @ApiOperation(value = "修改优惠卷信息")
    @PutMapping("/updateCoupon")
    public BaseResponse<Boolean> updateCoupon(@RequestBody UpdateCouponVO updateCouponVO) {
        return RespGenerator.returnOK(couponService.updateCoupon(updateCouponVO));
    }


    @ApiOperation(value = "新增优惠卷信息")
    @PostMapping("/addCoupon")
    public BaseResponse<Boolean> addCoupon(@RequestBody AddCouponVo addCouponVo) {

        return RespGenerator.returnOK(couponService.addCoupon(addCouponVo));
    }


    @ApiOperation(value = "删除优惠卷信息")
    @DeleteMapping("/deleteCoupon")
    public BaseResponse<Boolean> deleteCoupon(@RequestParam("couponId") Integer couponId) {

        return RespGenerator.returnOK(couponService.deleteCoupon(couponId));
    }


}
